<?php
/*
 * *********************************************************
 * ## Module controllers must extend MD_Controller class ##
 * *********************************************************
 */
class Home extends MD_Controller {
    
public function __construct()
{
    parent::__construct();

	/*
	 * ******************************************************************
	 * CHECK IF MODULE IS INSTALLED PROPERLY
	 * ******************************************************************
	 */
	$this->MODULE->config->load('module_config');	
	$short_name = $this->MODULE->config->item('short_name');
	$settings_table = $this->MODULE->config->item('settings_table');	 
	if(!$this->PACKAGE->security->app_modules->module_exist($short_name) || empty($short_name) || empty($settings_table))
	{
		$this->PACKAGE->errors->generate->code("001")->stop();
	}
    
            /*
             * ********************************************
             * LOAD LANGUAGE FILES FOR THIS MODULE ONLY
             * notice that some language files have been
             * loaded within MY_Controller core class
             * and those language files are common for all
             * modules
             * ********************************************
             */    
    
            $this->MODULE->lang->load('module_texts',LANGUAGE);
            
            /*
             * ********************************************
             * LOAD PACKAGES
             * ********************************************
             */
            $this->PACKAGE->core->packages->add('regional');   
			$this->PACKAGE->core->packages->add('routing');   
      
			/*
			 * ********************************************
			 * LOAD LIBRARIES
			 * ********************************************
			 */

	  
            /*
             * ********************************************
             * LOAD MODELS
             * ********************************************
             */
            $this->PACKAGE->regional->load->model('countries');
            $this->PACKAGE->regional->load->model('timezone');
						
			//$this->MODULE->load->model('module_mod_external');
			
			//$this->MODULE->load->library('module_translate');			           
}
    
public function index()
{
    /*
     * define data
     */          
    $data = array(
                    'title'       => lang('external_home_title'),
                    'description' => lang('external_home_desc'),
					'subpage' 	  => 'home'
                  );
          
    $data['countries'] = $this->PACKAGE->regional->countries->get_countries();

    /*
     * parse templates
     */
    
	$data['this'] = $this;
	
    $this->load->view('header',$data); // shared header
    
    $this->MODULE->load->view('module_header'); // module header    
    
    $this->MODULE->load->view('module_home'); // theme sample template              
    
    $this->MODULE->load->view('module_footer'); // module footer
     
    $this->load->view('footer'); // shared footer
    
    
}

}


?>
